Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive Python testing surface for the CUDA kernels by introducing nanobind-based bindings, a Python convenience wrapper layer, and a large pytest suite to validate kernel correctness and determinism.
Changes:
- Added a new nanobind binding layer (
kernel_binding.cpp+binding_utils.*) and wired it into the_pyllmqmodule build. - Improved error reporting across tensor dtype accessors and kernel dispatch wrappers (more informative unsupported-dtype / shape mismatch errors).
- Added Python
torch.library.custom_opwrappers and a large CUDA pytest suite to exercise the bound kernels.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utilities/tensor.h | Routes dtype mismatches through a helper function (but keeps constexpr accessors). |
| src/utilities/tensor.cpp | Implements throw_dtype_mismatch with a detailed message. |
| src/utilities/dtype.cpp | Accepts additional string aliases for FP8 dtype parsing. |
| src/kernels/swiglu.cu | Replaces asserts with runtime argument validation + safer size checks. |
| src/kernels/kernels.cpp | Centralizes “unsupported dtype” errors with dtype reporting for multiple tensors. |
| src/kernels/global_norm.cu | Minor formatting change to kernel launch. |
| src/kernels/encoder.cu | Updates vector load/store helpers and re-enables a kernel call. |
| src/kernels/bias.cu | Adds runtime validation for OC vectorization and improves exception type. |
| src/kernels/adamw.cu | Adds runtime validation for vectorization constraints. |
| src/binding/python/kernels.py | Python wrappers registering custom ops that call into _pyllmq. |
| src/binding/kernel_binding.cpp | New nanobind wrappers for most kernels (shape/dtype/device validation + argument extraction). |
| src/binding/binding_utils.h / .cpp | New shared utilities for dlpack dtype conversion and ndim checks. |
| src/binding/binding.cpp | Integrates the new kernel registration entrypoint. |
| scripts/test_kernels.py | Adds pytest coverage for many kernels (forward/backward, determinism, correctness). |
| CMakeLists.txt | Updates nanobind version and adds new binding sources to the Python module build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add python bindings for all kernels so we can more easily test them.